#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int slow = 0;
        int fast;
        int sum = 0;
        int min_len = 1e8;
        for(;slow<nums.size();slow++){
            fast = slow;
            sum = nums[fast];
            while(fast < nums.size()-1 && sum < target){
                fast++;
                sum+= nums[fast];
            }
            if(sum >= target){
                int cur_len = fast - slow + 1;
                min_len  = min(min_len,cur_len);
            }
        }
        return min_len==1e8 ? 0 : min_len;
    }
};

int main()
{
    Solution solution;
    vector<int> nums = {2,3,1,2,4,3};
    int target = 7;
    cout<<solution.minSubArrayLen(target,nums);
    return 0;
}